<?php 
/**[属性值模型]
 * @Author: 976123967@qq.com
 * @Date:   2014-11-08 15:01:39
 * @Last Modified by:   chenryoku
 * @Last Modified time: 2014-11-10 23:12:02
 */
class AttrValueModel extends Model{
	protected $tableName='attr_value';

	/**
	 * [add_attr_value 添加属性值]
	 * @param [type] $data [description]
	 */
	public function add_attr_value($data)
	{
		$this->add($data);
	}

	/**
	 * [get_attr_value_all 属性所有的值]
	 * @param  [type] $fid [description]
	 * @return [type]      [description]
	 */
	public function get_attr_value_all($attrId)
	{
		return  $this->where(array('attr_attr_id'=>$attrId))->order('attr_value_id asc')->select();
	}

	/**
	 * [del_attr_value_by_attr_id 通过属性attr_id删除属性值]
	 * @param  [type] $attrId [description]
	 * @return [type]         [description]
	 */
	public function del_attr_value_by_attr_id($attrId)
	{
		$this->where(array('attr_attr_id'=>$attrId))->delete();
	}

	/**
	 * [get_field_by_attr_value 获取指定字段通过属性值]
	 * @param  [type] $attrValue [description]
	 * @param  string $field     [description]
	 * @return [type]            [description]
	 */
	public function get_field_by_attr_value($attrValue,$field='attr_value_id')
	{	
		return $this->where(array('attr_value'=>$attrValue))->getField($field);
	}


	/**
	 * [get_field 获取指定的字段的值通过主键]
	 * @param  [type] $attrValueId [description]
	 * @param  string $field       [description]
	 * @return [type]              [description]
	 */
	public function get_field($attrValueId,$field = 'attr_value')
	{
		return $this->where(array('attr_value_id'=>$attrValueId))->getField($field);
	}
}